<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="/js/html5.min.js"></script>
    <script src="/js/respond.min.js"></script>
    <![endif]-->
</head>
<style>
    .layui-form-item .layui-input-inline {
        width: 300px!important;
    }

    .layui-upload-img {
        width: 92px;
        height: 92px;
        margin: 0 10px 10px 0;
    }
    .layui-upload-img{
        width: 92px;
        height: 92px;
        margin: 0 10px 10px 0;
        display: inline-block;
    }
    .layui-upload-list{
        display: flex;
    }
    .layui-table img {
        max-width: 50px;
    }

    .layui-upload-list li{
        position: relative;
    }
    .layui-upload-list li i{
        right: 10px;
        top: 0;
        position: absolute;
        background-color: red;
        width: 22px;
        height: 22px;
        line-height: 22px;
        color: #fff;
        text-align: center;
        font-size: 14px;
        border-radius: 100%;
        cursor: pointer;
    }
</style>

<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" id="form">
            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>企业名称</label>
                <div class="layui-input-inline">
                    <input type="text" value="<?= $list['name'] ?>"  name="company[name]"  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            
                        <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>简称</label>
                <div class="layui-input-inline">
                    <input type="text" value="<?= $list['shorter_form'] ?>"  name="company[shorter_form]"  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><span class="x-red">*</span>企业LOGO</label>
                <div class="layui-input-inline">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test1">上传图片</button>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" id="demo1" src="<?= $list['img'] ?>">
                        </div>
                    </div>
                    <input type="hidden" value="<?= $list['logo'] ?>"  id="logo"  name="company[logo]" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>企业行业</label>
                <div class="layui-input-inline">
                    <select name="company[industry]" lay-verify="required" lay-search="">
                        <?php foreach ($industry as $v): ?>
                            <option value="<?= $v['id'] ?>" <?php if ($v['id']==$list['industry']){?>selected<?php } ?>><?= $v['name'] ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>融资情况</label>
                <div class="layui-input-inline">
                    <select name="company[financing]" lay-verify="required" lay-search="">
                        <?php foreach ($financing as $v): ?>
                            <option value="<?= $v['id'] ?>" <?php if ($v['id']==$list['financing']){?>selected<?php } ?>><?= $v['name'] ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>

            <input type="hidden" name="company[id]" value="<?= $list['id'] ?>">

            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>企业人数</label>
                <div class="layui-input-inline">
                    <select name="company[number]" lay-verify="required" lay-search="">
                        <?php foreach ($number as $v): ?>
                            <option value="<?= $v['id'] ?>" <?php if ($v['id']==$list['number']){?>selected<?php } ?>><?= $v['name'] ?></option>
                        <?php endforeach; ?>
                    </select>

                </div>
            </div>




            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>企业官网</label>
                <div class="layui-input-inline">
                    <input type="url"  value="<?= $list['website'] ?>"  name="company[website]"  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>


            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>基本信息简述</label>
                <div class="layui-input-inline">
                    <textarea type="text" style="resize: none;height: 150px"   name="company[desc]"  lay-verify="required" autocomplete="off" class="layui-input"><?= $list['desc'] ?></textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="phone" class="layui-form-label"><span class="x-red">*</span>热门企业</label>
                <div class="layui-input-block">
                    <input type="radio" name="company[hot]" value="10" title="是"  <?php if ($list['hot']==10){?>checked<?php } ?>>
                    <input type="radio" name="company[hot]" value="20" title="否" <?php if ($list['hot']==20){?>checked<?php } ?>>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>排序</label>
                <div class="layui-input-inline">
                    <input type="text" value="<?= $list['sort'] ?>"   name="company[sort]"  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux"><span class="x-red">*</span>越小排越前</div>
            </div




            <div class="layui-form-item">
                <label  class="layui-form-label"><span class="x-red">*</span>企业环境照片</label>
                <div class="layui-input-inline">
                    <div class="layui-input-inline">
                        <div class="layui-upload">
                            <button type="button" class="layui-btn" id="test2">选择图片</button>

                            <div class="layui-upload-list" id="demo2">
                                <?php foreach ($img as $v): ?>
                                    <li><img src="<?=$v['img']?>" class="layui-upload-img">
                                        <i onclick="delimg(this)" data-id="<?=$v['id'] ?>">X</i>
                                    </li>
                                <?php endforeach; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
                        <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>公司地址</label>
                <div class="layui-input-inline">
                    <input type="text" id="local" value="<?= $list['address'] ?>"   name="company[address]"  lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                           <div class="layui-form-mid layui-word-aux"><span class="x-red">*</span>(位置搜索后自动填写)</div>
            </div>
            
            
                    <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>经度</label>
                <div class="layui-input-inline">
                    <input type="text"  value="<?= $list['lng'] ?>"   name="company[lng]" id="lng" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
   <div class="layui-form-mid layui-word-aux"><span class="x-red">*</span>(位置搜索后自动填写)</div>
            </div>
            
            
            
            <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>纬度</label>
                <div class="layui-input-inline">
                    <input type="text"  value="<?= $list['lat'] ?>"   name="company[lat]" id="lat" lay-verify="required" autocomplete="off" class="layui-input">
                </div>
       <div class="layui-form-mid layui-word-aux"><span class="x-red">*</span>(位置搜索后自动填写)</div>
            </div>
            
            
               <div class="layui-form-item">
                <label for="username" class="layui-form-label"><span class="x-red">*</span>位置</label>
                <div class="layui-input-inline" style="height: 400px;width:800px!important;">
                <iframe src="https://qolaxin.gzfloat.com/?r=index/map" frameborder="0" scrolling="no" style="width: 100%;height: 100%;"></iframe>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label"></label>
                <button type="button"  class="layui-btn" id="btn">保存</button>
            </div>
        </form>
    </div>
</div>
<script>
    //删除图片
    function delimg(obj){
        $.post('/?r=company/delimg',{id:obj.dataset.id},function (e) {
            var e=JSON.parse(e);//解析json字符串为对象s
            if (e.code){
                obj.parentNode.remove();
            }else{
                obj.parentNode.remove();
            }
        });
    }

    layui.use(['layer','form','upload'],function() {
        var layer = layui.layer;
        var upload = layui.upload;
        $ = layui.jquery;


        //多图片上传
        upload.render({
            elem: '#test2'
            ,field:'imageFile'
            ,url: '/?r=admin-base/upload'
            ,multiple: true
            ,before: function(obj){

            }
            ,done: function(res){
                $('#demo2').append('<li><img src="'+ res.url +'" alt="'+ 1 +'" class="layui-upload-img"><i onclick="delimg(this)" data-id="'+ res.img_id +'">x</i><input type="hidden" name="img_id[]" value="'+ res.img_id +'"></li>');

            }
        });

        //普通图片上传
        upload.render({
            elem: '#test1'
            ,field:'imageFile'
            ,url: '/?r=admin-base/upload'
            ,before: function(obj){}
            ,done: function(res){
                if (res.code){
                    $('#demo1').attr('src', res.url); //图片链接（base64）
                    $('#logo').val(res.img_id); //图片链接（base64）
                }else{
                    layer.alert(res.msg);
                }
            }
        });

        $('#btn').click(function () {
            $.ajax({
                type: "POST",//方法类型
                dataType: "json",//预期服务器返回的数据类型
                url:'/?r=company/edit',
                data:new FormData(document.getElementById("form")),
                processData:false,
                contentType:false,
                success: function (res) {
                    if (res.code){
                        layer.msg(res.msg);
                        setTimeout(function () {
                           parent.location.reload();
                        },500);

                    }else{
                        layer.msg(res.msg);
                    }
                },
                error : function() {

                }
            });
        });


    });



</script>
</body>

</html>
